﻿using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Windows.Forms;
using coliseu.BussinessLayer;

namespace coliseu.Views.Servicos
{
    public partial class FrmCadTipoServico : Form
    {
       private Tipo_servicoBL rBL;
        private tipo_servico r;

        public FrmCadTipoServico(Tipo_servicoBL rBL)
        {
            InitializeComponent();
            this.rBL = rBL;
            tipo_servicoBindingSource.AddNew();
        }

        public FrmCadTipoServico(tipo_servico r, Tipo_servicoBL rBL)
        {
            InitializeComponent();
            this.rBL = rBL;
            this.r = r;
            tipo_servicoBindingSource.DataSource = r;
        }
        private void FrmCadTipoServico_Load(object sender, EventArgs e)
        {
           
        }

        private void toolStripButton3_Click(object sender, EventArgs e)
        {
            Close();
        }

        private void toolStripButton1_Click(object sender, EventArgs e)
        {
            ValidateChildren();
            Validate();

            tipo_servicoBindingSource.EndEdit();

            if (r == null)
                rBL.salvar((tipo_servico)tipo_servicoBindingSource.Current, "insert");
            else
                rBL.salvar((tipo_servico)tipo_servicoBindingSource.Current, "edit");

            MessageBox.Show("Salvo com sucesso", "Atenção", MessageBoxButtons.OK, MessageBoxIcon.Information);
            Close();
        }
    }
}
